#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(int argc, char const *argv[])
{
    int tol=0;
    srand(50);
    printf("\n**********catch thirty********\n");
    printf("Game Begin\n");
    randomize();
    if(rand()*2==1)
        tol=input(tol);
    while (tol!=30)
        if((tol=copu(tol))==30)
            printf("YOU ARE LOSE!\n");
        else
            if((tol=input(tol))==30)
            printf("I LOSE!\n");
        printf("**********Game Over***********\n");
    return 0;
}
int input(int t)
{
    int a;
    do
    {
        printf("Please count:");
        scanf("%d",&a);
        if(a>2||a<1||t+a>30)
        printf("Error input,again!");
        else
            printf("Your count:%d\n",t+a);
    } while (a>2||a<1||t+a>30);
    return (t+a);
}
int copu(int s)
{
    int c;
    printf("Computer count:");
    if((s+1)%3==0)
        printf(" %d\n",++s);
    else if((s+2)%3==0)
    {
        s+=2;
        printf(" %d\n",s);
    }
    else
    {
        c=rand()*2+1;
        s+=c;
        printf("%d\n",s);
    }
    return s;
}